<template>
  <div class="contain">
    <div class="headertitle">
      <span>
        <router-link to="/position">
          <i class="el-icon-back" style="color: black"></i>
          <span style="margin-left: 10px; color: #4b5563">返回</span>
        </router-link>
      </span>
      <h1>职业详情</h1>
    </div>
    <div class="section">
      <div class="sheader">
        <div class="shtop">
          <div class="sthleft">
            <h1>{{ tableData.postname }}</h1>
            <p>
              <el-button size="mini" plain v-if="tableData.status == 0"
                >未审核</el-button
              >
              <el-button
                type="success"
                size="mini"
                plain
                v-if="tableData.status == 1"
                >正常</el-button
              >
              <el-button
                type="danger"
                size="mini"
                plain
                v-if="tableData.status == 2"
                >已退回</el-button
              >
              <span style="color: #2563eb; font-weight: 500">30k-50·13薪</span>
              <span>{{ tableData.address }}</span>
              <span>{{ tableData.degree }}及以上</span>
              <span>3-5年经验</span>
              <span>{{ tableData.type }}</span>
            </p>
          </div>
          <div class="sthright">
            <div>
              <el-tag type="warning" v-if="tableData.status == 0"
                >待审核</el-tag
              >
              <el-tag type="success" v-else-if="tableData.status == 1"
                >已通过</el-tag
              >
              <el-tag type="danger" v-else>已拒绝</el-tag>
            </div>
            <span style="color: #6b7280; font-size: 16px"
              >发布时间：{{ tableData.createtime }}</span
            >
          </div>
        </div>
        <div class="shbottom">
          <img src="../../assets/images/IMG@2x.png" alt="" />
          <div class="shbtext">
            <h1>{{ tableData.company }}</h1>
            <p>
              <span>互联网</span>
              <span>500-1000人</span>
              <span>民营企业</span>
            </p>
          </div>
        </div>
      </div>
      <div class="smainbox">
        <h1>职位描述</h1>
        <ul>
          {{
            tableData.introduction
          }}
          <!-- <li>本科及以上学历，计算机相关专业</li>
            <li>3年以上前端开发经验，熟悉 React、Vue 等主流框架</li>
            <li>深入理解 JavaScript、HTML5、CSS3</li>
            <li>有大型项目开发经验，熟悉前端工程化</li>
            <li>良好的团队协作能力和沟通能力</li> -->
        </ul>
      </div>
      <div class="contactbox" v-show="tableData.reasons">
        <h1>退回理由</h1>
        <p>{{ tableData.reasons }}</p>
      </div>
    </div>
    <div class="footer">
      <el-button v-if="tableData.status == 0" @click="handlerefused"
        >退回</el-button
      >
      <el-button v-if="tableData.status == 1" @click="handlerefused"
        >退回</el-button
      >
      <el-button v-if="tableData.status == 2" disabled>已退回</el-button>
    </div>
    <!--  退回按钮操作 -->
    <el-dialog title="退回理由" :visible.sync="refusedbox" width="500px">
      <el-form :model="Betwnform">
        <el-form-item>
          <el-input v-model="Betwnform.reasons" autocomplete="off"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="refusedbox = false">取 消</el-button>
        <el-button
          type="primary"
          @click="handleYesrefusedbox(Betwnform.reasons)"
          >确 定</el-button
        >
      </div>
    </el-dialog>
  </div>
</template>
  
  <script>
import { getId, update } from "../../api/position/index";
export default {
  data() {
    return {
      refusedbox: false,
      Betwnform: {},
      tableData: [{}],
    };
  },
  mounted() {
    const id = this.$route.query.id;
    console.log("Received ID:", id);
    // 进行操作
    this.selectclin(id);
  },
  methods: {
    handlerefused() {
      this.refusedbox = true;
    },
    //获取数据
    async selectclin(id) {
      let res = await getId({ id: id });
      if (res.code == 200) {
        console.log("resres", res);
        this.tableData = res.data;
        console.log("this.tableData", this.tableData);
      } else {
        this.$message.error("数据获取失败或格式不正确");
      }
    },
    handleYesrefusedbox(e) {
      const passobj = {
        status: 2,
        id: this.tableData.id,
        reasons: e,
      };
      this.$confirm("是否退回?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          update(passobj).then((res) => {
            this.refusedbox = false;
            this.$router.push({ path: `/position` });
            this.$message({
              type: "success",
              message: "退回成功!",
            });
          });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "取消退回",
          });
        });
    },
  },
};
</script>
  
  <style lang="scss" scoped>
.contain {
  width: 100%;
  min-height: 100vh;
  background-color: #f9fafb;

  .headertitle {
    padding-left: 40px;
    width: 100%;
    height: 50px;
    background-color: white;
    display: flex;
    align-items: center;

    h1 {
      font-size: 18px;
      color: black;
      margin-top: 10px;
      margin-left: 30px;
      font-weight: 600;
    }
  }
}

//  分页
.bottom {
  width: 100%;
  height: 50px;
  background-color: white;
  border-bottom-right-radius: 15px;
  border-bottom-left-radius: 15px;
  .paging {
    width: 100%;
    height: 30px;
    padding: 0px 48px 0px 0px;
    margin: 0 24px 24px;
    .el-pagination {
      display: flex;
      justify-content: space-between;
    }
  }
}

.sheader {
  width: 95%;
  background-color: white;
  border-radius: 10px;
  margin: 20px auto;
  padding: 20px;
  box-sizing: border-box;

  .shtop {
    width: 100%;
    height: 80px;
    background-color: white;
    display: flex;
    justify-content: space-between;
    border-bottom: 1px solid #ccc;

    .sthleft {
      width: 50%;

      h1 {
        font-size: 20px;
        font-weight: 600;
      }

      p {
        span {
          margin-right: 20px;
        }
      }
    }
    .sthright {
      width: 280px;
      display: flex;
      justify-content: space-between;
    }
  }

  .shbottom {
    width: 100%;
    height: 100px;
    display: flex;
    align-items: center;

    img {
      height: 64px;
      width: 64px;
      margin-right: 20px;
    }

    .shbtext {
      h1 {
        font-size: 16px;
        font-weight: 600;
        margin-top: 10px;
      }

      p {
        span {
          margin: 0px 10px 0px 0px;
        }
      }
    }
  }
}

.smainbox {
  width: 95%;
  background-color: white;
  margin: 10px auto;
  border-radius: 20px;
  padding: 10px 30px;
  box-sizing: border-box;

  h1 {
    font-size: 18px;
    font-weight: 600;
    line-height: 60px;
  }
}
// 退回理由盒子
.contactbox {
  width: 95%;
  margin: 10px auto;
  background-color: white;
  padding: 20px;
  margin-top: 20px;
  border-radius: 10px;

  h1 {
    font-size: 20px;
    font-weight: 600;
  }
}
.footer {
  display: flex;
  justify-content: right;
  padding: 20px;
}
</style>